package cn.edu.zjut.medlinebackend.model;

import cn.edu.zjut.medlinebackend.model.dto.PictureEsDTO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import lombok.Data;

/**
 * 
 * @TableName picture
 */
@TableName(value ="picture")
@Data
public class Picture implements Serializable {
    /**
     * 图片id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 图片识别的内容
     */
    private String content;

    /**
     * 所在文件的id
     */
    private Long fileId;

    /**
     * 是否被删除  0--没有删除   1--已被删除
     */
    private Integer isdelete;

    /**
     * 更新时间
     */
    private Date updatetime;
    /**
     * 图片名
     */
    private String imgtitle;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Picture other = (Picture) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
            && (this.getFileId() == null ? other.getFileId() == null : this.getFileId().equals(other.getFileId()))
            && (this.getImgtitle() == null? other.getImgtitle()==null :this.getImgtitle().equals(other.getImgtitle()))   ;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
        result = prime * result + ((getFileId() == null) ? 0 : getFileId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", content=").append(content);
        sb.append(", fileId=").append(fileId);
        sb.append(", imgtitle=").append(imgtitle);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    public PictureEsDTO toDTO() {
        PictureEsDTO pictureEsDTO = new PictureEsDTO();
        pictureEsDTO.setId(this.id);
        pictureEsDTO.setContent(this.content);
        pictureEsDTO.setFileId(this.fileId);
        pictureEsDTO.setUpdateTime(this.updatetime);
        pictureEsDTO.setIsDelete(this.isdelete);
        pictureEsDTO.setImgtitle(this.imgtitle);
        return pictureEsDTO;
    }
}